class Vertex:

    def __init__(self, identity):
        self.identity = identity
        self.measures = {}
        self.contact = set()
        self.contact_edge = set()

    def __eq__(self, other):
        if isinstance(other, Vertex):
            other = other.identity
        return self.identity == other

    def add_measure(self, neighbor, pattern, score):
        if isinstance(neighbor, Vertex):
            neighbor = neighbor.identity
        if neighbor not in self.measures:
            scores = [str(self.identity) + '-' + str(neighbor)]
            for _ in range(9):
                scores.append(0)
            self.measures[neighbor] = scores

        scores = self.measures[neighbor]
        scores[pattern] += score

    def get_measure(self, item):
        return self.measures[item]

    def add_contact(self, edge):
        item = edge.get_other(self.identity)
        if isinstance(item, Vertex):
            item = item.identity
        self.contact.add(item)
        self.contact_edge.add(edge)

    def get_neighbor(self):
        neighbors = []
        directions = []
        edges = []

        for edge in self.contact_edge:
            neighbor = edge.get_other(self)
            direct = 2
            if edge.start_with(self):
                direct = 1
            if neighbor not in neighbors:
                neighbors.append(neighbor)
                directions.append(direct)
                edges.append([edge])
                continue
            index = neighbors.index(neighbor)
            if direct != directions[index]:
                directions[index] = 3
            edges[index].append(edge)
        return neighbors, directions, edges
